package com.my.kindlesend.config;

import com.my.kindlesend.interceptor.WxLoginInterceptor;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * WebMvc配置类
 * 用于注册拦截器等Web相关配置
 */
@Configuration
@RequiredArgsConstructor
public class WebMvcConfig implements WebMvcConfigurer {

    private final WxLoginInterceptor wxLoginInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册微信登录拦截器
        registry.addInterceptor(wxLoginInterceptor)
                // 拦截所有请求
                .addPathPatterns("/**")
                // 排除不需要拦截的请求
                .excludePathPatterns(
                        "/swagger-ui/**",
                        "/v3/api-docs/**",
                        "/error"
                );
    }
}